package com.wangwenshuo.goods.controller;

import com.wangwenshuo.goods.api.GoodsApi;
import com.wangwenshuo.goods.entity.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class Client02Controller {
    @Autowired
    private GoodsApi goodsApi;

    @RequestMapping("selects")
    public String selectGoods(Goods goods, @RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum, @RequestParam(value = "pageSize",defaultValue = "3")Integer pageSize){
        System.out.println(goods);
        String url = goodsApi.selectGoods(goods,pageNum,pageSize);

        return url;
    }

    @RequestMapping("del")
    public String del(String ids){
        return goodsApi.del(ids);
    }

    @RequestMapping("getById")
    public String getById(Integer id){
        return goodsApi.getById(id);
    }

    @RequestMapping("save")
    public String save(@RequestBody Goods goods){
        return goodsApi.save(goods);
    }
}
